In C, as free() knows an array size, why isn't there a function that gets the array size? [closed]

Posted by user354959 on Stack Overflow See other posts from Stack Overflow or by user354959
Published on 2010-05-31T23:44:54Z Indexed on 2010/06/01 1:53 UTC
Read the original article Hit count: 236

Filed under:
|
|
|
|

Possible Duplicate:
If free() knows the length of my array, why can’t I ask for it in my own code?

Searching around (including here at stackoverflow), I got that malloc() allocates an array and also creates a header to control the array info.

In this header, there's also the array size. free() use such information to know how to deallocate that array.

So, if the array size info is "there" (somewhere in the memory), why there isn't a function that returns an array size, looking for this at the array header? Or am I missing something?

© Stack Overflow or respective owner

Related posts about c

    Related posts about array